package com.yejiarong.elasticsearch.service;

import com.yejiarong.elasticsearch.api.bean.request.DeleteByQueryForm;
import com.yejiarong.elasticsearch.api.bean.request.GetRequestForm;
import com.yejiarong.elasticsearch.api.bean.request.SaveRequestForm;
import com.yejiarong.elasticsearch.api.bean.request.SearchRequestForm;
import com.yejiarong.elasticsearch.api.bean.response.DeleteByQueryResult;
import com.yejiarong.elasticsearch.api.bean.response.DeleteResult;
import com.yejiarong.elasticsearch.api.bean.response.SaveResult;
import com.yejiarong.elasticsearch.api.bean.response.SearchPageResult;

import java.util.Map;

/**
 * @author YeJR
 */
public interface IElasticsearchService {

    /**
     * 文档是否存在
     * @param index 索引
     * @param documentId 文档ID
     * @return 是否存在
     */
    boolean documentExists(String index, String documentId);

    /**
     * 索引文档
     * @param saveRequestForm 请求
     * @return SaveResponse
     */
    SaveResult indexDocument(SaveRequestForm saveRequestForm);

    /**
     * 更新文档
     * @param saveRequestForm 请求
     * @return SaveResponse
     */
    SaveResult updateDocument(SaveRequestForm saveRequestForm);

    /**
     * 删除文档
     * @param index 索引
     * @param documentId 文档ID
     * @return  DeleteResponse
     */
    DeleteResult deleteDocument(String index, String documentId);

    /**
     * 通过查询条件删除文档
     * @param deleteByQueryForm 查询条件
     */
    DeleteByQueryResult deleteDocumentByQuery(DeleteByQueryForm deleteByQueryForm);

    /**
     * 文档ID查询
     * @param getRequestForm 请求
     */
    Map<String, Object> getDocumentById(GetRequestForm getRequestForm);

    /**
     * 搜索文档
     * @param searchRequestForm 请求
     */
    SearchPageResult searchDocument(SearchRequestForm searchRequestForm);
}
